    //加载百度地图底图
    var map = new BMap.Map('allmap',{minZoom:13,maxZoom:19,enableMapClick:false});
    //设置中心点坐标
    map.centerAndZoom(new BMap.Point(113.307649675, 23.1200491021),13);
    window.map = map;
    var heatOverlays;//热力图覆盖物
    var pointOverlays;//散点图覆盖物
    var allMapData = [];//地图数据
    var inputData = [];//参数
    var mapDataStatus ;//返回状态
    var boundaryData = [];//边界数据
    var scrollFlag = true;//监听地图层级状态
    var searchFlag = false;//地图搜索状态
    var initMapUrl = "/map/initMapData",//地图初始化接口
        communityUrl = "/map/mapCommunityData",//小区数据接口
        buildingUrl = "/map/mapBuildingData";//楼栋数据接口
    var urlParams = window.location.search;
    if(urlParams.indexOf("?")!=-1){
        getUrlParams(urlParams);
    }
    //根据url获取地图类型
    var currentMap = inputData['currentMap'];
    if(urlParams.indexOf("flag=true")!=-1){//是否由其他页面跳转到地图
        var level;
        var city = inputData["city"];
        var district = inputData["district"];
        var communityId = inputData["communityId"];
        if(city=="-1"){
            level="1";
        }else if(district!="-1" && (!communityId || communityId=="-1")){
            level="4";
        }else if(communityId){
            level="5";
        }else{
            level="3";
        }
        inputData["level"]=level;
        if(level =="1"){//全国
            searchFlag=false;
            map.centerAndZoom(new BMap.Point(106.530635013,29.5446061089),6);
            initMap(initMapUrl,inputData);
        }else if(level =="3"){//市
            $("#city").val(city);
            $("#city").change();
        }else if(level =="4"){//行政区
            endisableScroll(map);
            getDistrict();
            var inputData = getInputData();
            inputData.district=district;
            map.clearOverlays();
            RequestData(communityUrl,inputData);
            map.centerAndZoom(new BMap.Point(allMapData[0].lng,allMapData[0].lat),16);
            createCommunity(allMapData);
        }else if(level =="5"){//小区
            endisableScroll(map);
            getDistrict();
            var inputData = getInputData();
            inputData.district=district;
            inputData.communityId=communityId;
            //查询小区坐标
            RequestData(communityUrl,inputData);
            var communityName= allMapData[0].communityName;
            var communityId = allMapData[0].communityId;
            var lng = allMapData[0].lng;
            var lat = allMapData[0].lat;
            map.clearOverlays();
            RequestData("/map/mapBuildingBankData",inputData);
            map.centerAndZoom(new BMap.Point(lng,lat),19);
            createBuilding_bank(allMapData,boundaryData,new BMap.Point(lng,lat),"abc.png",communityName,communityId);
        }
    }else{
        $("#city").change();
    }
    //注册地图层级监听
    map.addEventListener("zoomend",scrollFunc);
    //请求接口
    function RequestData (url,paramsData) {
        $.ajax({
            type: "post",
            url: url,
            data:paramsData,
            async: false,
            success:function (data) {
                allMapData = data.result.mapDataList;
                mapDataStatus = data.result.mapDataStatus;
                if(currentMap=="clusterMap"){
                    boundaryData = data.result.boundaryList;
                }
            }
        })
    }
    //监听地图层级事件
    function scrollFunc (e) {
        e=e || window.event;
        var zoom = map.getZoom();
        var zoneNumber = $("#city").val();
        if(!zoneNumber || zoneNumber=="-1") {
            return;
        }
        var inputData = {currentMap:currentMap,city:zoneNumber};
        if(zoom>=13 && zoom<16 && scrollFlag){
            map.clearOverlays();
            if(currentMap=="pointMap"){
                pointOverlays.clearMarkers();
            }
            initMap(initMapUrl,inputData);
            searchFlag=false;
        }else if(zoom>=16 && zoom<=19 && scrollFlag){
            map.clearOverlays();
            if(currentMap=="pointMap"){
                pointOverlays.clearMarkers();
                if(zoom>=18 && zoom<=19){
                    var bs = map.getBounds();   //获取可视区域
                    var bssw = bs.getSouthWest();   //可视区域左下角
                    var bsne = bs.getNorthEast();   //可视区域右上角
                    var bsswLeft = bssw.lng + "," + bssw.lat;
                    var bsneRight = bsne.lng + "," + bsne.lat;
                    inputData.leftTop = bsswLeft;
                    inputData.rightUp = bsneRight;
                    RequestData (buildingUrl,inputData);
                    createBuilding(allMapData,map);
                }else{
                    initMap(initMapUrl,inputData);
                }
            }else{
                RequestData (communityUrl,inputData);
                createCommunity(allMapData);
            }
            searchFlag=false;
        }
    }
    //获取url参数
    function getUrlParams(urlParams){
        var str = urlParams.substr(1);
        var params = str.split("&");
        for(var i = 0; i < params.length; i ++) {
            inputData[params[i].split("=")[0]]=(params[i].split("=")[1]);
        }

    }





